package com.bosssoft.boss_exam_db.service.busines.impl;

import com.bosssoft.boss_exam_db.entity.ExamPaperQuestion;
import com.bosssoft.boss_exam_db.mapper.ExamPaperQuestionMapper;
import com.bosssoft.boss_exam_db.service.base.impl.BaseServiceImpl;
import com.bosssoft.boss_exam_db.service.busines.ExamPaperQuestionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
@Slf4j
public class ExamPaperQuestionServiceImpl extends BaseServiceImpl<ExamPaperQuestion> implements ExamPaperQuestionService {

    //注入ExamPaperQuestionMapper
    @Autowired
    private ExamPaperQuestionMapper examPaperQuestionMapper;


    /***
     * @Author lys(cherish)
     * @Phone 17720799636
     * @Date  2019/4/8
     * @Description 插入试卷问题
     * @Param [companyId, examPaperQuestions] 公司ID，试卷-问题记录
     * @Return java.lang.Integer
     * @Exception
     * @since JDK 1.8
     **/
    @Override
    public Integer insertPaperQuestions(String companyId,List<ExamPaperQuestion> examPaperQuestions) {
        examPaperQuestions.stream().forEach(examPaperQuestion -> {
            examPaperQuestion.setCompanyId(companyId);
            int i = examPaperQuestionMapper.insertSelective(examPaperQuestion);
            if(i!=1){
                throw new RuntimeException("批量为试卷配置题目失败");
            }
        });
        return 1;
    }
}
